﻿// base_BlueprintScript.cpp : 此文件包含 "main" 函数。程序执行将在此处开始并结束。
//

#include <iostream>
#include <sstream>
#include "base/Control.h"
#include "Context.h"
#include "base/Window.h"
#include "MainWindow.h"
#include "ClassWindow.h"
#include "BlueprintClassLoader.h"
#include "ProjectWindow.h"


//Context c;
struct  ab
{
	int* a;
	int* b;
};
std::string get_cpuid()
{

	unsigned long a = 0;

	unsigned long d = 0;

	__asm

	{

		mov eax, 01h

		xor edx, edx

		cpuid

		mov d, edx

		mov a, eax

	};

	char s[256] = { 0 };

	sprintf_s(s, "%08X%08X", d, a);

	//unsigned int hashcode = Tfuns::ELFHash((unsigned char*)s, strlen(s));

	//unsigned int cpuid = hashcode % 1000;
	return s;
}
int main(int argc, char* argv[])
{
	std::string str = "void func(a,b)";
	str.pop_back();
	str.pop_back();
	str.pop_back();
	str.pop_back();

	// c.OnInit();
	std::string cpuId = get_cpuid();
	printf("%s", BIND_CPU);
	if (cpuId != BIND_CPU)
	{
		printf("该CPU[%s] 不能运行,请联系作者\r\n", cpuId.data());
		return 0;
	}
	/*std::string str = "void func(a,b)";
	char ch1[512];
	memset(ch1, 0, 100);
	char ch2[100];
	memset(ch2, 0, 100);
	char ch3[100];
	memset(ch3, 0, 100);
	char ch4[100];
	memset(ch4, 0, 100);
	int a = 4;
	int b = 5;
	int s = sscanf_s("123avcda", "%[1-9]",ch1);
	std::cout << s<<std::endl;
	std::cout << ch1<<std::endl;
	std::cout << ch2<<std::endl;
	std::cout << ch3<<std::endl;
	std::cout << ch4<<std::endl;*/
	// MainWindow mw;
   /* ab* o = new ab;
	o->a = new int(12);
	o->b = new int(34);
	int** in = &o->a;
	*(*in) = 2333;*/
	//  const char* ch = "1001_1,1002_3,1004_5";
	  /* char* pCh = const_cast<char*>(ch);
	   char ch0[20];
	   char ch1[20];
	   char ch2[20];

	   char pch1[22];
	   while (sscanf_s(ch, "%d_%d", &d, &e) == 2)
	   {
		   printf("%d,%d\r\n", d, e);
		   ch += sprintf_s(pch1, "%d_%d", d, e);
	   }*/
	ProjectWindow mw;
	//ClassWindow mw;
	mw.MakeWindow();
	mw.ShowModal();
	//BlueprintClassLoader clLoader;
	//clLoader.SaveFile("MY52.xml");
	////clLoader.LoadFile("1.xml");
	/*BlueprintClassLoader loader;
	loader.cls = mw.bc;
	loader.SaveFile("2.bp");*/
	return 0;
}
#include <iostream>
#include <filesystem>
namespace fs = std::filesystem;

void SearchDir(const std::string& path, std::vector<std::string>& vctFileList)
{
	if (fs::exists(path) && fs::is_directory(path)) {
		for (const auto& entry : fs::directory_iterator(path)) {
			std::string childPath = entry.path().string();
			if (fs::is_regular_file(entry.status())) {
				int r = childPath.rfind(".bp");
				if (childPath.rfind(".bp") != std::string::npos)
				{
					std::cout << entry.path() << "r:" << childPath[r] << std::endl;
					//files.push_back(path);
					vctFileList.push_back(childPath);
				}
				else {
					std::cout << entry.path() << " bp:" << childPath.rfind(".bp") << std::endl;
				}
			}
			else if (fs::is_directory(entry.status()))
			{
				SearchDir(childPath, vctFileList);
			}
		}
	}
	else {
		std::cerr << "Path does not exist or is not a directory." << std::endl;
	}
}

int mains(int argc, char* argv[]) {


	std::string path = ".\\.bp"; // 替换为你的目录路径
	using namespace std;
	try {
	/*	std::vector<std::string> v;
		SearchDir(path,v);*/
		int r = path.rfind(".bp");
		cout << r << endl;
		cout << r + 3 << endl;
		cout << path.size() << endl;
	}
	catch (const fs::filesystem_error& e) {
		std::cerr << e.what() << std::endl;
	}
	return 0;
}

// 运行程序: Ctrl + F5 或调试 >“开始执行(不调试)”菜单
// 调试程序: F5 或调试 >“开始调试”菜单

// 入门使用技巧: 
//   1. 使用解决方案资源管理器窗口添加/管理文件
//   2. 使用团队资源管理器窗口连接到源代码管理
//   3. 使用输出窗口查看生成输出和其他消息
//   4. 使用错误列表窗口查看错误
//   5. 转到“项目”>“添加新项”以创建新的代码文件，或转到“项目”>“添加现有项”以将现有代码文件添加到项目
//   6. 将来，若要再次打开此项目，请转到“文件”>“打开”>“项目”并选择 .sln 文件
